//
//  AppDelegate.m
//  UI07_UITabbarController
//
//  Created by Hanlingyu on 16/7/22.
//  Copyright © 2016年 ltq. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    _window.backgroundColor = [UIColor whiteColor];
    [_window makeKeyAndVisible];
    
    
    // tabbarController 标签视图控制
    // 主要管理没层级关系的视图控制器
    // 1. viewControllers 所有被管理的视图控制器, 都在这个数组中,
    //    可以通过setter方法的形式, 去赋值
    //    也可以通过下述方法进行视图控制器数组的赋值
    // 2. setViewControllers:animated
    // 3. 通过一数组创建完成后, 如果数组中的控制器没有设置 tabbarItem, 则显示一个空的tabBarItem
    // 4. tabBarItem 根据自己需求去创建对应的tabBarItem
    //    UIViewController的属性(Category)
    //    因为: 每个视图控制器的tabBarItem都不一样, 因为不能设为TabBarController的属性
    // 创建方式:
    //  1> initWithTabBarSystemItem:tag: 根据系统样式创建
    //  2> initWithTitle:image:tag: 根据自定义的图片与文字创建
    //  3> initWithTitle:image:selectedImage:tag: 根据自定义的图片与文字创建, 增添选中图片
    // 5. 如果数组个数过多(多余5时), 系统会把多余出来的内容, 统一使用一种方式去管理
    //  建议: 不要超过五个
    // 6. tabBar (高度 49)
    //  1> barTintColor bar的背景色
    //  2> tintColor  bar上元素的颜色
    //  3> translucent bar是否透明
    //  4> badgeValue 角标
    // 7. UIAppearance
    
    UITabBarController *tabbar = [[UITabBarController alloc] init];
//    [[UITabBar appearance] setTintColor:[UIColor yellowColor]];
//    [[UITabBar appearance] setBarTintColor:[UIColor lightGrayColor]];
////    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
//    [[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];
//    // 改标题字体颜色
//    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];
//    // VC中self.title 与 self.navigationItem.title有区别
//    // 1. self.title 会修改两个内容 navigationItem.title 和 tabBarItem.title
//    // 2. self.navgationItem.title 只修改navgationBar上的标题
//    
//    
//    
//    ViewController  *vc1 = [[ViewController alloc] init];
//    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:vc1];
//    navigation.navigationItem.title = @"测试";
//    
//    vc1.view.backgroundColor = [UIColor redColor];
//    vc1.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:200];
//    vc1.tabBarItem.badgeValue = @"未读";
//    navigation.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"text" image:nil tag:0];
//    vc1.title = @"测试";
//    
//    
//    
//    ViewController  *vc2 = [[ViewController alloc] init];
//    vc2.view.backgroundColor = [UIColor yellowColor];
//    vc2.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"视频" image:nil tag:201];
//
//    ViewController  *vc3 = [[ViewController alloc] init];
//    vc3.view.backgroundColor = [UIColor greenColor];
//    
//    vc3.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"电影" image:nil tag:202];
//
//    ViewController  *vc4 = [[ViewController alloc] init];
//    vc4.view.backgroundColor = [UIColor cyanColor];
//    vc4.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"个人设置" image:nil tag:203];
//    
//    ViewController  *vc5 = [[ViewController alloc] init];
//    vc5.view.backgroundColor = [UIColor cyanColor];
//    vc5.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"设置" image:nil tag:204];
//    
//    ViewController  *vc6 = [[ViewController alloc] init];
//    vc6.view.backgroundColor = [UIColor cyanColor];
//    vc6.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"个人" image:nil tag:205];
//    
//    ViewController  *vc7 = [[ViewController alloc] init];
//    vc7.view.backgroundColor = [UIColor cyanColor];
//    vc7.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"逗比" image:nil tag:206];
//
//    [tabbar setViewControllers:@[navigation, vc2, vc3, vc4, vc5, vc6, vc7]];
////    tabbarController.tabBar.barTintColor = [UIColor greenColor];
////    tabbarController.tabBar.tintColor = [UIColor whiteColor];
//    tabbar.tabBar.translucent = NO;
    
    ViewController *vc = [[ViewController alloc] init];
    UINavigationController *navgation = [[UINavigationController alloc] initWithRootViewController:vc];
    [tabbar setViewControllers:@[navgation]];
    
    // 设置tabbarItem时, 给你要放进数组中的控制器去设置
    navgation.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"新闻" image:nil tag:1000];
    
    // 设置标题
//    vc.title = @"News";
    vc.navigationItem.title = @"News";
    
    _window.rootViewController = tabbar;
    
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
